<?php

include_once 'config.php';
global $extensions;

ob_start();
$get = array_merge($_GET, $_POST);

$dirname = $_SERVER["DOCUMENT_ROOT"]. $get["dir"];

$out = "[";
if($dirname && is_dir($dirname)) {
	
	$dir = opendir($dirname);

	if($dir) {
		while ($f = readdir($dir)) {
			if (preg_match('/\.'.implode('$|\.', $extensions).'$/i', $f)) {
				$out .= "'$f',";
			}
		}
	}
}
$out = preg_replace('/,$/',"",$out)."]";
ob_get_clean();

echo $out;
?>